package 练习;

import java.util.Random;

public class GenerateArray {
    public static void main(String[] args) {
        int[] a = generateArray(5,100);
        System.out.println("数组长度为:"+a.length);
        for (int i= 0;i<a.length;i++){
            System.out.println(a[i]);
        }
        int[] b = generateArray(10,50);
        System.out.println("第一个元素值为:"+b[0]);
        for (int i =0;i<b.length;i++){
            System.out.println(b[i]);
        }
    }
    public static int[] generateArray(int len,int max){
        Random rand = new Random();
        int[] arr =new int[len];
        for (int i =0;i<arr.length;i++){
            arr[i] = rand.nextInt(max+1);
        }
        return arr;
    }

}
